var comboxWithTree,comboxWithTreeHj,comboxWithTreeXz,comboxWithTreeHj_op,comboxWithTreeXz_op;
var inputObj;
Ext.onReady(function() {
	Ext.useShims = true;
	Ext.SSL_SECURE_URL = "../ext-3.2.1/resources/images/default/s.gif";
	Ext.BLANK_IMAGE_URL = "../ext-3.2.1/resources/images/default/s.gif";
	Ext.util.CSS.swapStyleSheet('theme', parent.currentTheme);
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';
	
	//省份加载数据
	var districtStore = new Ext.data.Store({
		proxy : new Ext.data.ScriptTagProxy({
			url : '../district/loadDistrict.action?pid=-1'
		}),
		fields : ['value', 'label'],
		reader : new Ext.data.ArrayReader({}, [{
			name : 'value',
			type : 'string'
		}, {
			name : 'label',
			type : 'string'
		}]),
		remoteSort : false
	});
	districtStore.load();
	var districtCombox = new Ext.form.ComboBox({
		store : districtStore,
		displayField : 'label',
		hiddenName : 'districtStore',
		valueField : 'value',
		typeAhead : true,
		editable : false,
		mode : 'local',
		value : proviceName,
		triggerAction : 'all',
		selectOnFocus : true,
		width : 210
	});
    
    /*
    organizationCombox.on('select',function(){
    	$("#provice").val(organizationCombox.getValue());
    	$("#city").val(organizationCombox.getRawValue());
    })
    
    */
    districtCombox.render(Ext.get('districtCombox'));
    
    	//省份选择后自动更新市级数据
	districtCombox.on('select', function() {
		districtCombox_child.clearValue();
		districtStore_child.proxy = new Ext.data.ScriptTagProxy({
			url : '../district/loadDistrict.action?pid='
					+ districtCombox.getValue()
		});
		districtStore_child.reload();
	})
    
    //市级
	var districtStore_child = new Ext.data.Store({
		proxy : new Ext.data.ScriptTagProxy({
			url : '../district/loadDistrict.action?pid='+proviceId
		}),
		fields : ['value', 'label'],
		reader : new Ext.data.ArrayReader({}, [{
			name : 'value',
			type : 'string'
		}, {
			name : 'label',
			type : 'string'
		}]),
		remoteSort : false
	});
	districtStore_child.reload();
	var districtCombox_child = new Ext.form.ComboBox({
		store : districtStore_child,
		displayField : 'label',
		hiddenName : 'districtStore_child',
		valueField : 'value',
		typeAhead : true,
		editable : false,
		mode : 'local',
		value : districtName,
		triggerAction : 'all',
		selectOnFocus : true,
		width : 210
	});
    districtCombox_child.render(Ext.get('districtCombox_child'));
    
    districtCombox_child.on('select',function(){
    	$("#districtId").val(districtCombox_child.getValue());
    	$("#city").val(districtCombox_child.getValue());
    })
    
    parent.save_fun = function(value) {
    // return obj = document.forms[0];
    	if(districtCombox_child.getValue()==''){
    		alert('请选择地区');
    		return false;
    	}else{
    		document.forms[0].submit();
    		alert('保存成功');
    	}
    }
})

function goBackReset(){
    parent.closeDH();
}